import 'package:flutter/material.dart';
import 'package:search_people/utils/util.dart';

class PersonDynamicModel {
  String? id;
  String? leaderBaseinfoId;
  String? name;
  String? title;
  String? source;
  String? overview;
  String? releaseTime;
  String? link;
  String? labels;
  List<String>? labelList;
  dynamic createBy;
  dynamic createTime;
  dynamic updateBy;
  dynamic updateTime;

  bool get hasLinkPerson {
    return !isNilStr(name);
  }

  List<Color>? labelColors;

  PersonDynamicModel({
    this.id,
    this.leaderBaseinfoId,
    this.name,
    this.title,
    this.source,
    this.overview,
    this.releaseTime,
    this.link,
    this.labels,
    this.labelList,
    this.createBy,
    this.createTime,
    this.updateBy,
    this.updateTime,
  });

  factory PersonDynamicModel.fromJson(Map<String, dynamic> json) {
    List ll = json['labelList'];
    return PersonDynamicModel(
      id: json['id'] as String?,
      leaderBaseinfoId: json['leaderBaseinfoId'] as String?,
      name: json['name'].toString(),
      title: json['title'] as String?,
      source: json['source'] as String?,
      overview: json['overview'] as String?,
      releaseTime: json['releaseTime'] as String?,
      link: json['link'] as String?,
      labels: json['labels'] as String?,
      labelList: ll.map((e) => e.toString()).toList(),
      createBy: json['createBy'] as dynamic,
      createTime: json['createTime'] as dynamic,
      updateBy: json['updateBy'] as dynamic,
      updateTime: json['updateTime'] as dynamic,
    );
  }

  Map<String, dynamic> toJson() => {
        'id': id,
        'leaderBaseinfoId': leaderBaseinfoId,
        'title': title,
        'source': source,
        'overview': overview,
        'releaseTime': releaseTime,
        'link': link,
        'labels': labels,
        'labelList': labelList,
        'createBy': createBy,
        'createTime': createTime,
        'updateBy': updateBy,
        'updateTime': updateTime,
      };
}
